<template>
	<view class="content">
		<view class="filter-box">
			<uni-data-select 
				v-model="type" 
				placeholder="请选择设备类型" 
				:localdata="typeList" 
				@change="change"></uni-data-select>
			<uni-data-select 
				v-model="area" 
				placeholder="请选择区域" 
				:localdata="areaList" 
				@change="change"></uni-data-select>
		</view>

		<view class="page-container" scroll-y="true">
			<view v-for="item in list" class="list-item">
				<view class="type-status" :class="item.status==1 ? 'success' : 'fail'"></view>
				<view class="list-item-center">
					<view class="mt10 mb10">设备名称</view>
					<view class="mt10 mb10">累积雨量：<text style="color: #28B93D">100mm</text></view>
					<view>地下水水位：<text style="color: #CC851E">20M</text></view>
				</view>
				<view class="list-item-right">
					<view class="mt10 mb10">更新时间：2023-02-02 18:00</view>
					<view class="mt10 mb10">雨强：<text style="color: #31C9E8">0.00mm/h</text></view>
					<view>埋深：<text style="color: #2B38CC">5M</text></view>
				</view>
			</view>		
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				triggered: false,
				type: '',
				area: '',
				typeList: [
					{ value: 0, text: "篮球" },
					{ value: 1, text: "足球" },
					{ value: 2, text: "游泳" },
				],
				areaList: [
					{ value: 0, text: "篮球" },
					{ value: 1, text: "足球" },
					{ value: 2, text: "游泳" },
				],
				list: [
					{name: '设备名称', updateTime: '2023-02-02 16:21', accumulatedRainfall: '100mm', RainIntensity: '0.00mm/h', groundwaterLevel: '20M', buriedDepth: '5M', status: 1},
					{name: '设备名称', updateTime: '2023-02-02 16:21', accumulatedRainfall: '100mm', RainIntensity: '0.00mm/h', groundwaterLevel: '20M', buriedDepth: '5M', status: 2},
					{name: '设备名称', updateTime: '2023-02-02 16:21', accumulatedRainfall: '100mm', RainIntensity: '0.00mm/h', groundwaterLevel: '20M', buriedDepth: '5M', status: 2},
					{name: '设备名称', updateTime: '2023-02-02 16:21', accumulatedRainfall: '100mm', RainIntensity: '0.00mm/h', groundwaterLevel: '20M', buriedDepth: '5M', status: 1},
					{name: '设备名称', updateTime: '2023-02-02 16:21', accumulatedRainfall: '100mm', RainIntensity: '0.00mm/h', groundwaterLevel: '20M', buriedDepth: '5M', status: 1},
					{name: '设备名称', updateTime: '2023-02-02 16:21', accumulatedRainfall: '100mm', RainIntensity: '0.00mm/h', groundwaterLevel: '20M', buriedDepth: '5M', status: 1},
					{name: '设备名称', updateTime: '2023-02-02 16:21', accumulatedRainfall: '100mm', RainIntensity: '0.00mm/h', groundwaterLevel: '20M', buriedDepth: '5M', status: 2},
					{name: '设备名称', updateTime: '2023-02-02 16:21', accumulatedRainfall: '100mm', RainIntensity: '0.00mm/h', groundwaterLevel: '20M', buriedDepth: '5M', status: 1},
					{name: '设备名称', updateTime: '2023-02-02 16:21', accumulatedRainfall: '100mm', RainIntensity: '0.00mm/h', groundwaterLevel: '20M', buriedDepth: '5M', status: 1},
					{name: '设备名称', updateTime: '2023-02-02 16:21', accumulatedRainfall: '100mm', RainIntensity: '0.00mm/h', groundwaterLevel: '20M', buriedDepth: '5M', status: 1},
					{name: '设备名称', updateTime: '2023-02-02 16:21', accumulatedRainfall: '100mm', RainIntensity: '0.00mm/h', groundwaterLevel: '20M', buriedDepth: '5M', status: 1},
					{name: '设备名称', updateTime: '2023-02-02 16:21', accumulatedRainfall: '100mm', RainIntensity: '0.00mm/h', groundwaterLevel: '20M', buriedDepth: '5M', status: 1},
					{name: '设备名称', updateTime: '2023-02-02 16:21', accumulatedRainfall: '100mm', RainIntensity: '0.00mm/h', groundwaterLevel: '20M', buriedDepth: '5M', status: 1},
					{name: '设备名称', updateTime: '2023-02-02 16:21', accumulatedRainfall: '100mm', RainIntensity: '0.00mm/h', groundwaterLevel: '20M', buriedDepth: '5M', status: 1}
				]
			};
		},
		
		onLoad() {
			this._freshing = false;
			setTimeout(() => {
				this.triggered = true;
			}, 1000)
		},
		
		methods: {
			change(e) {
				
			},
			
			onPulling(e) {
				console.log("onpulling", e);
			},
			onRefresh() {
				if (this._freshing) return;
				this._freshing = true;
				setTimeout(() => {
					this.triggered = false;
					this._freshing = false;
				}, 3000)
			},
			onRestore() {
				this.triggered = 'restore'; // 需要重置
				console.log("onRestore");
			},
			onAbort() {
				console.log("onAbort");
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;
		padding: 20upx;
	}
	.filter-box {
		display: flex;
		align-items: center;
		justify-content: space-around;
		width: 100%;
		position: fixed;
		left: 0;
		top: 0;
		z-index: 999;
		background: #fff;
	}
	
	::v-deep .uni-stat__select {
		width: 300upx !important;
		.uni-select__input-box {
			height: 50upx !important;
		}
		.uni-select {
			height: 50upx;
		}
	}
	
	.page-container {
		padding: 10upx;
		box-sizing: border-box;
		padding-top: 50upx;
		.list-item {
			display: flex;
			position: relative;
			padding-left: 30upx;
			box-sizing: border-box;
			height: 170upx;
			border-bottom: 2upx solid #E6E6E6;
		}
		.type-status {
			width: 22upx;
			height: 22upx;
			background: #ddd;
			border-radius: 100%;
			position: absolute;
			left: 0;
			top: 15upx;
			&.success{
				background: #28B93D;
			}
			&.fail {
				background: #BA2E26;
			}
		}
		.list-item-center, .list-item-right {
			display: flex;
			flex-direction: column;
			font-size: 26upx;
		}
		.list-item-center{
			width: 45%;
		}
		
		.list-item-right {
			width: 55%;
		}
		
		.mt10 {
			margin-top: 10upx;
		}
		.mb10 {
			margin-bottom: 10upx;
		}
	}
	
</style>
